import Vue from 'vue';
import VueRouter from 'vue-router';
Vue.use(VueRouter);

let routes=[
    {
        path: '/login',
        component: resolve => require(['../views/Login.vue'], resolve),   //路由懒加载
        name: 'login',
        hidden: true
    },
    {
        path: '/404',
        component: resolve => require(['../views/404.vue'], resolve),
        name: 'notFound',
        hidden: true
    },
    {
        path: '/',
        component: resolve => require(['../views/index.vue'], resolve),
        children:[
            {
                path: '',
                component: resolve => require(['../views/Streamer.vue'], resolve),
                name: 'home',
                meta: {
                    requiresAuth: true
                }
            },
            {
                path: '/streamer',
                name: 'streamer',
                component: resolve => require(['../views/Streamer.vue'], resolve),
                meta: {
                    requiresAuth: true
                }
            },
            {
                path: '/history',
                name: '历史事件信息',
                component: resolve => require(['../views/HistoryInfo.vue'], resolve),
                meta: {
                    requiresAuth: true
                }
            },
            {
                path: '/settings',
                name: '配置选项',
                component: resolve => require(['../views/Settings.vue'], resolve),
                children:[
                    {
                        path: 'user',
                        name: '用户信息管理',
                        components: {
                            settingsInfo: resolve => require(['../views/SettingsUserInfo.vue'], resolve)
                        },
                        meta: {
                            requiresAuth: true,
                            isRoot:true
                        }
                    },
                    {
                        path: 'scheme',
                        name: '方案信息管理',
                        components: {
                            settingsInfo: resolve => require(['../views/SettingsSchemeInfo.vue'], resolve)
                        },
                        meta: {
                            requiresAuth: true,
                            isRoot:true
                        }
                    },
                    {
                        path: 'stream_service',
                        name: '视频流服务管理',
                        components: {
                            settingsInfo: resolve => require(['../views/SettingsStreamServiceInfo.vue'], resolve)
                        },
                        meta: {
                            requiresAuth: true,
                            isRoot:true
                        }
                    }
                    
                ]
            },
            {
                path: '/statistics',
                name: 'statistics',
                component: resolve => require(['../views/Statistics.vue'], resolve),
                meta: {
                    requiresAuth: true
                }
            }
        ]
    },
    {
        path: '*',
        hidden: true,
        redirect: { path: '/404' }
    }
];
export default new VueRouter({
    routes
});